package nowcoder.written_examination.meituan;

import org.junit.Test;

import java.util.Scanner;

/**
 * @author fance
 * @date 18-7-4 上午5:58
 */
public class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int w = scanner.nextInt();
            int y = scanner.nextInt();
            double x = scanner.nextDouble();
            int n = scanner.nextInt();
        }
    }
    public int getDis(int[] A, int n) {
        if (A == null || n < 1) {
            return 0;
        }
        int max = 0;
        int nowMin = A[0];
        for (int i = 0; i < n; i++) {
            nowMin = Math.min(nowMin,A[i]);
            max = Math.max(max,A[i] - nowMin);
        }
        return max;
    }

    public int[][] flipChess(int[][] A, int[][] f) {
        // write code here
        for (int i = 0; i < f.length; i++) {
            int x = --f[i][0];
            int y = --f[i][1];
            flipChessCore(A,x,y);
        }
        return A;
    }
    private void flipChessCore(int[][] a,int x,int y) {
        if (x > 0) {
            int curX = x - 1;
            a[curX][y] = a[curX][y] == 1 ? 0 : 1;
        }
        if (x < a.length - 1) {
            int curX = x + 1;
            a[curX][y] = a[curX][y] == 1 ? 0 : 1;
        }
        if (y > 0) {
            int curY = y - 1;
            a[x][curY] = a[x][curY] == 1 ? 0 : 1;
        }
        if (y < a[0].length - 1) {
            int curY = y + 1;
            a[x][curY] = a[x][curY] == 1 ? 0 : 1;
        }
    }

    public int countArea(int[] A, int n) {
        // write code here
        if (A == null || n < 1) {
            return 0;
        }
        int max  = 0;
        for (int i = 0; i < A.length - 1; i++) {
            int min = A[i];
            for (int j = i + 1; j < A.length; j++) {
                min = Math.min(min,A[j]);
                max = Math.max(max,(j - i + 1) * min);
            }
        }
        return max;
    }

    @Test
    public void test() {
        int[][] a = {{0,0,1,1},{1,0,1,0},{0,1,1,0},{0,0,1,0}};
        int[][] f = {{2,2},{3,3},{4,4}};
        int[] A = {2,7,9,4,1};
        int[] A2 = {281,179,386,165,88,500};
        System.out.println(countArea(A2,6));
        System.out.println(countArea(A,5));
//        System.out.println(Arrays.toString(flipChess(a,f)));
    }
}
